home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / private / _chins.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  2KB  |  80 lines

  1. #include <string.h>
  2. #define    CURSES_LIBRARY    1
  3. #include <curses.h>
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid__chins = "$Header: C:\CURSES\private\RCS\_chins.c 2.1 1993/06/18 20:23:13 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   PDC_chins()    - Low-level insert character in window
  15.  
  16.   PDCurses Description:
  17.      This is a private PDCurses routine.
  18.  
  19.      This routine provides the basic functionality for the X/Open
  20.      [mv][w]insch() routines.  The xlat flag indicates that normal
  21.      character translation is performed or not.  If not, then the
  22.      character is output as is.
  23.  
  24.      The 'xlat' flag is TRUE for the normal curses routines.
  25.  
  26.   PDCurses Return Value:
  27.      This function returns OK on success and ERR on error.
  28.  
  29.   PDCurses Errors:
  30.      It is an error to call this function with a NULL window pointer.
  31.  
  32.   Portability:
  33.      PDCurses    int PDC_chins( WINDOW* win, chtype c, bool xlat );
  34.  
  35. **man-end**********************************************************************/
  36.  
  37. int    PDC_chins(WINDOW *win, chtype c, bool xlat)
  38. {
  39.     int    retval = ERR;
  40.     int    x;
  41.     int    y;
  42.     int    maxx;
  43.     int    offset;
  44.     chtype* temp1;
  45.     char    ch    = (c & A_CHARTEXT);
  46.  
  47. #ifdef PDCDEBUG
  48.     if (trace_on) PDC_debug("PDC_chins() - called\n");
  49. #endif
  50.  
  51.     if (win == (WINDOW *)NULL)
  52.         return( retval );
  53.  
  54.     x    = win->_curx;
  55.     y    = win->_cury;
  56.     maxx    = win->_maxx;
  57.     offset    = 1;
  58.     temp1    = &win->_y[y][x];
  59.  
  60.     if ((ch < ' ') && xlat)
  61.     {
  62.         offset++;
  63.     }
  64.  
  65.     memmove( temp1+offset, temp1, (maxx - x -offset) * sizeof(chtype) );
  66.  
  67.     win->_lastch[y] = maxx-1;
  68.  
  69.     if ((win->_firstch[y] == _NO_CHANGE) ||
  70.         (win->_firstch[y] > x))
  71.     {
  72.         win->_firstch[y] = x;
  73.     }
  74.     /*
  75.      * PDC_chadd() fixes CTRL-chars too
  76.      */
  77.     retval = (PDC_chadd(win, c, xlat,FALSE));
  78.     return( retval );
  79. }
  80.